home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlb20 / lib / times.c < prev    next >
C/C++ Source or Header  |  1991-11-16  |  787b  |  38 lines

  1. #include <sys/times.h>
  2. #include <time.h>
  3. #include <mintbind.h>
  4.  
  5. extern int __mint;
  6. extern long _childtime;
  7.  
  8. /* macro to convert milliseconds into CLK_TCKs */
  9. #define CVRT(x) ((x)/((1000L/CLK_TCK)))
  10.  
  11. int
  12. times(buffer)
  13. struct tms *buffer;
  14. {
  15.     long usage[8], r, real_time;
  16.  
  17.     real_time = clock();
  18.  
  19.     if (__mint) {
  20.         r = Prusage(usage);
  21.         if (r >= 0 && buffer) {
  22.             buffer->tms_cutime = CVRT(usage[3]);
  23.             buffer->tms_cstime = CVRT(usage[2]);
  24.             buffer->tms_utime = CVRT(usage[1]);
  25.             buffer->tms_stime = CVRT(usage[0]);
  26.             return real_time;
  27.         }
  28.     }
  29.  
  30.     if (buffer) {
  31.         buffer->tms_cstime = (time_t) 0;
  32.         buffer->tms_cutime = (time_t) _childtime;
  33.         buffer->tms_stime = (time_t) 0;
  34.         buffer->tms_utime = (time_t) real_time - _childtime;
  35.     }
  36.     return real_time;
  37. }
  38.